<template>
    <el-main>
        <p>定时任务管理</p>
        <div class="btnStyle"><el-button type="primary"  size="small" @click="openCampaignOrder()">开启订单定时检查任务</el-button></div>
        <div class="btnStyle"><el-button type="primary"  size="small" @click="openResourceRelease()">开启定时发布资源任务</el-button></div>
        <div class="btnStyle"><el-button type="primary"  size="small" @click="startCampaignsRelease()">开启活动定时发布任务</el-button></div>
        <div class="btnStyle"><el-button type="primary"  size="small" @click="stopResourceRelease()">关闭定时发布资源任务</el-button></div>
        <div class="btnStyle"><el-button type="primary"  size="small" @click="stopCampaignOrder()">关闭活动订单检查任务</el-button></div>
        <div class="btnStyle"><el-button type="primary"  size="small" @click="stopCampaignsRelease()">关闭活动定时发布任务</el-button></div>
    </el-main>
</template>

<script>
    import {
        startCampaignOrderSchedule,
        startResourceReleaseSchedule,
        stopCampaignOrderSchedule,
        stopResourceReleaseSchedule,
        startCampaignsReleaseSchedule,
        stopCampaignsReleaseSchedule
    } from "@/api/table";
    export default {
        name: "SCHEDULE",
        methods: {
            //开启活动订单定时检查任务
            openCampaignOrder(){
                startCampaignOrderSchedule().then(result => {
                    if(result.data.isSuccessful === 'Y'){
                        console.log(result);
                        this.$message({
                            message: "设置成功！",
                            type: "success"
                        });
                        this.init();
                    } else{
                        this.$message.error(result.data.message);
                    }
                }).catch(err => {});
            },
            //开启资源文件定时发布任务
            openResourceRelease(){
                startResourceReleaseSchedule().then(result => {
                    console.log(result);
                    if(result.data.isSuccessful === 'Y'){
                        console.log(result);
                        this.$message({
                            message: "设置成功！",
                            type: "success"
                        });
                        this.init();
                    } else{
                        this.$message.error(result.data.message);
                    }
                }).catch(err => {});
            },
            //关闭活动订单定时检查任务
            stopCampaignOrder(){
                stopCampaignOrderSchedule().then(result => {
                    if(result.data.isSuccessful === 'Y'){
                        console.log(result);
                        this.$message({
                            message: "设置成功！",
                            type: "success"
                        });
                        this.init();
                    } else{
                        this.$message.error(result.data.message);
                    }
                }).catch(err => {});
            },
            //关闭资源文件定时发布任务
            stopResourceRelease(){
                stopResourceReleaseSchedule().then(result => {
                    console.log(result);
                    if(result.data.isSuccessful === 'Y'){
                        console.log(result);
                        this.$message({
                            message: "设置成功！",
                            type: "success"
                        });
                        this.init();
                    } else{
                        this.$message.error(result.data.message);
                    }
                }).catch(err => {});
            },
            startCampaignsRelease(){
                startCampaignsReleaseSchedule().then(result => {
                    console.log(result);
                    if(result.data.isSuccessful === 'Y'){
                        console.log(result);
                        this.$message({
                            message: "设置成功！",
                            type: "success"
                        });
                        this.init();
                    } else{
                        this.$message.error(result.data.message);
                    }
                }).catch(err => {});
            },
            //关闭活动定时发布任务
            stopCampaignsRelease(){
                stopCampaignsReleaseSchedule().then(result => {
                    console.log(result);
                    if(result.data.isSuccessful === 'Y'){
                        console.log(result);
                        this.$message({
                            message: "设置成功！",
                            type: "success"
                        });
                        this.init();
                    } else{
                        this.$message.error(result.data.message);
                    }
                }).catch(err => {});
            },
        },
    }

</script>

<style scoped>
    .btnStyle{
        margin-top: 20px;
    }
</style>
